package org.hisp.dhis.wsclient.dao.mockup;

import java.util.Vector;

import org.hisp.dhis.wsclient.dao.DatasetDAO;
import org.hisp.dhis.wsclient.model.DataElement;
import org.hisp.dhis.wsclient.model.DataValue;
import org.hisp.dhis.wsclient.model.Dataset;
import org.hisp.dhis.wsclient.model.OrganisationUnit;
import org.hisp.dhis.wsclient.model.Period;

public class MockupDatasetDAO
    implements DatasetDAO
{

    private Vector datasets;
    private Dataset dataset;

    public MockupDatasetDAO()
    {
        datasets = new Vector();
        for ( int i = 0; i < 10; ++i )
        {
            Dataset dataset = new Dataset();
            dataset.setName( "Dataset " + String.valueOf( i ) );
            datasets.addElement( dataset );
        }

        Vector elements = new Vector();
        Vector values = new Vector();
        DataElement el;
        DataValue val;

        el = new DataElement();
        el.setName( "Element 1 (str)" );
        el.setType( "string" );
        elements.addElement( el );

        el = new DataElement();
        el.setName( "Element 2 (str with value)" );
        el.setType( "string" );
        elements.addElement( el );
        val = new DataValue();
        val.setValue( "abc" );
        val.setDataElement( el );
        values.addElement( val );

        el = new DataElement();
        el.setName( "Element 3 (int)" );
        el.setType( "int" );
        elements.addElement( el );

        el = new DataElement();
        el.setName( "Element 4 (int with value)" );
        el.setType( "int" );
        elements.addElement( el );
        val = new DataValue();
        val.setValue( "123" );
        val.setDataElement( el );
        values.addElement( val );

        el = new DataElement();
        el.setName( "Element 5 (bool)" );
        el.setType( "bool" );
        elements.addElement( el );

        el = new DataElement();
        el.setName( "Element 6 (bool with value)" );
        el.setType( "bool" );
        elements.addElement( el );
        val = new DataValue();
        val.setValue( "1" );
        val.setDataElement( el );
        values.addElement( val );

        dataset = new Dataset();
        dataset.setId( 99 );
        dataset.setName( "Dataset99" );
        dataset.setDataElements( elements );
        dataset.setDataValues( values );

    }

    public Vector listDatasets( OrganisationUnit orgUnit )
    {

        return datasets;
    }

    public Dataset getDataset( OrganisationUnit orgUnit, Period period, Dataset dataset )
    {
        System.out.println( "Hello" );
        System.out.println( this.dataset == null );
        return this.dataset;
    }

    public void saveDataset( Dataset dataset )
    {
        // TODO Auto-generated method stub

    }

}
